package net.xinqushi.java8stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Spliterator;

/**
 * @author xjie 2019/7/22 15:19
 * @see java.util.Iterator 语法糖 syntactic sugar
 * @see net.xinqushi.java8stream.Concurrent  a parallel traversal example
 */
public class CollectionStreams {

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        for(int i = 0 ; i < 10 ; i++){
            list.add(i+ "");
        }
        for (String item : list ) {//语法糖 for-each loop equals to use iterator
            System.out.println(item);
        }
        //Spliterator is an other way to traverse collection that just like iterator
        //difference from two traverse way is that Spliterator supports a parallel way to traverse collection
        Spliterator<String> spliterator = list.spliterator();
        spliterator.forEachRemaining(System.out::println);
    }
}
